Skip to content

Conversation

@luigidellaquila
Copy link
Contributor

Moving the validation to the level of single settings, based on their snapshot flag.

Also doing some refactoring to inject specific validation for project_routing, based on CPS being enabled, and to make unit tests easier to write.

@elasticsearchmachine elasticsearchmachine added v9.3.0 Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) labels Oct 27, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

Copy link
Contributor

@ivancea ivancea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

With some luck, this PR adding SET tests is merged soon too, so the SET statement is "fully scaffolded"

import org.elasticsearch.Build;
import org.elasticsearch.transport.RemoteClusterService;

public class SettingsValidationContext {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: As the tests are subclassing this, and to avoid calling Build.current().isSnapshot() multiple times in production, maybe this should be a record (crossProjectEnabled, isSnapshot), and have a custom constructor accepting the RemoteClusterService and calling isSnapshot().
Maybe this approach is somewhat shortsighted if we want to add more derived states or services, so take it with a grain of salt!


public void testValidate_ProjectRouting_noCps() {
var setting = QuerySettings.PROJECT_ROUTING;
assumeTrue("CPS validation not enabled yet", setting.preview());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this check dangerous, as we may forget about it, and not test it later even if it's already implemented.
This is actually a commented test under the hood; maybe we should just comment it, and add a comment with the why.
More visible than an assumption that will never be truthy

@luigidellaquila
Copy link
Contributor Author

Thanks @ivancea!

@luigidellaquila luigidellaquila enabled auto-merge (squash) October 27, 2025 16:26
@luigidellaquila luigidellaquila merged commit 5e61b1e into elastic:main Oct 28, 2025
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL >non-issue Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants